#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: find.sh
# Description: 
#   Find out how many file descriptors are being used   
# Edit History: 
#   2010-12-22    File created.
#========================================================================

#Step 1. Find out program PID

#Let us find out PID for mysqld process
ps aux | grep mysqld
#mysql    32149  0.6  0.6 163432 11864 ?        Ssl  Dec17  46:51 /usr/sbin/mysqld

#OR
pid=`pidof mysqld`

#Output:
#28290

#Step 2. List file opened by pid 28290

#Use lsof command or /proc/PID file system to display fd lists:
lsof -p $pid

#OR
cd /proc/$pid/fd
ls -l | less
#You can count open file, enter:
ls -l | wc -l
